/*
** 3117.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Wed Oct  1 18:58:48 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "3117.h" */
#include <stdio.h>

int main()
{
     int tscore, score, match, country;
     char dump[20];

     while(scanf("%d %d", &country, &match)){
	  if (country + match == 0)
	       break;
	  tscore = 0;
	  while(country){
	       scanf("%s %d", dump, &score);
	       tscore += score;
	       country--;
	  }
	  printf("%d\n", match - (tscore - 2 * match));
     }

     return 0;
}

